<?php 

require_once(dirname(__FILE__).'/commons/CFPropertyList.php');
require_once(dirname(__FILE__).'/database/functions.php');

header("Content-type: application/xml");

function makePlist($allCursos=null) 
{
	$plist = new CFPropertyList();
	$plist->add( $dict = new CFDictionary());

	if ($allCursos != null ) {
		$plistCursos = new CFArray();
		foreach ($allCursos as $curso) {

			$plistCurso = new CFDictionary();
			$plistCurso->add('Nombre', new CFString($curso['nombre']));
			$plistCurso->add('Descripcion', new CFString($curso['descripcion']));
			$plistCursos->add($plistCurso);
		}
		$dict->add('cursos', $plistCursos);
	
	}
	return $plist->toXML();
}

switch($_SERVER['REQUEST_METHOD']) {

		
		
		
	case('GET'):
		//print_r($path_params);
		if ($path_params[1] != null) {

		}
		else {
			$allCursos = getCursos();
			echo makePlist($allCursos);

		}

		break;
}